package bill.layuiboot.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * 拦截器配置
 * @author Bill Ludwig; 2020/5/31 21:51
 */
@EnableTransactionManagement
@Configuration
@MapperScan("bill.layuiboot.mapper")
public class MPConfig {

    @Bean
    public PaginationInterceptor interceptor() {
        var interceptor = new PaginationInterceptor();
        interceptor.setCountSqlParser(new JsqlParserCountOptimize(true));

        return interceptor;
    }
}
